package controllers;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.List;

import models.Expert;
import play.Play;
import play.libs.Images;
import play.mvc.Controller;

public class Experts extends Controller{
	
	 public static void index() {
	        render();
	    }
         
         
          /**
     * Get depts json.
     */
    public static void json(int page, int pagesize) {
    	
    	List<Expert> experts = Expert.all().fetch(page, pagesize);      	 
    	long total = Expert.count();
    	
    	HashMap<String,Object> obj = new HashMap<String,Object>();
    	obj.put("Rows", experts);
    	obj.put("Total", total);
    	renderJSON(obj);
    }
         
     /**
     * Update a expert.
     */
    public static void save(Expert expert) {  
        expert.save();
        renderJSON("");
    }
    
    /**
     * Delete a expert.
     */
    public static void delete(long id) {
        Expert.findById(id)._delete();
        renderJSON("");
    }
    
 
 
    
     
}
